package com.xinhe.web.controller;

import com.querydsl.core.QueryResults;
import com.xinhe.web.common.Result;
import com.xinhe.web.entity.OrderPay;
import com.xinhe.web.request.ServiceCenterQuery;
import com.xinhe.web.service.AliyunService;
import com.xinhe.web.service.OrderPayService;
import com.xinhe.web.service.ServiceCenterService;
import com.xinhe.web.util.ValidatorUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@Api(value = "订单支付", tags = {"订单支付"})
@RestController
@RequestMapping(value = {"/orderPay"}, produces = {"application/json;charset=UTF-8"})

public class OrderPayController {
    @Autowired
    private OrderPayService orderPayService;
    @ApiOperation(httpMethod = "GET", value = "分页查询订单支付")
    @RequestMapping({"/pageOrderPay"})
    public QueryResults<OrderPay> pageOrderPay(Long userId, Long orderId, int pageNum, int pageSize) {
        return this.orderPayService.pageOrderPay(userId, orderId, pageNum,  pageSize);
    }

    @ApiOperation(httpMethod = "POST", value = "保存订单支付")
    @RequestMapping({"/saveOrderPay"})
    public Result saveOrderPay(String orderIdsStr,String payChannel) {
        return this.orderPayService.saveModel(orderIdsStr,payChannel);
    }
    @ApiOperation(httpMethod = "POST", value = "请求支付订单")
    @PostMapping({"/requestPayOrder"})
    public Result requestPayOrder(String orderIdsStr,String payChannel) {
        return this.orderPayService.requestPayOrder(orderIdsStr,payChannel);
    }

    @ApiOperation(httpMethod = "POST", value = "微信支付订单回调")
    @PostMapping({"/responseOrderPayNotify/{configId}"})
    public Result responseOrderPayNotify() {
        return this.orderPayService.responseOrderPayNotify();
    }

    @ApiOperation(httpMethod = "GET", value = "删除订单支付")
    @ApiImplicitParam(name = "orderPayId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/deleteOrderPay"})
    public Result deleteOrderPay(Long orderPayId) {
        return this.orderPayService.delete(orderPayId);
    }
    @ApiOperation(httpMethod = "GET", value = "订单支付详情")
    @ApiImplicitParam(name = "orderPayId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/detailOrderPay"})
    public Result<OrderPay> detailOrderPay(Long orderPayId) {
        return this.orderPayService.findById(orderPayId);
    }
    @ApiOperation(httpMethod = "GET", value = "订单微信退款回调")
    @RequestMapping({"/responseWeixinRefundOrderNotify/{configId}"})
    public Result responseWeixinRefundOrderNotify(@PathVariable("configId") Long configId) {
        return this.orderPayService.responseWeixinRefundOrderNotify(configId);
    }
    @ApiOperation(httpMethod = "POST", value = "余额支付")
    @RequestMapping({"/requestBalancePay"})
    public Result requestBalancePay(Long orderId) {
        return this.orderPayService.requestBalancePay(orderId);
    }



}
